﻿@model PortalNews.NewsData.New
@{
    PortalNews.NewsData.New[] arrNews = ViewBag.arrNews;
    Lang lang = ViewBag.Lang;
}
<style>
    .page
    {
        width: 1200px;
        margin-left: auto;
        margin-right: auto;
    }
    #c-english, #c-vietname
    {
        width: 565px;
    }
    #c-vietname
    {
        margin-right: 5px;
    }
    #c-english
    {
    }
    
</style>
@{ Html.BeginForm(); }
<div id="c-news">
    <div class="d-title" style="margin: 10px;">
        @lang.CREATENEWS</div>
    <div id="c-vietname" class="left">
        <h2 class="sub-title">@lang.VIETNAM</h2>
        @Html.Hidden("arrNews[0].ID", arrNews[0].ID)
        @Html.Hidden("arrNews[0].LangID", arrNews[0].LangID)
        <div class="row">
            <label class="c-label">@lang.TITLE</label>
            @Html.TextBox("arrNews[0].Title", arrNews[0].Title, new { @class = "input t-input", required = "required" })
        </div>
        <div class="row">
            <label class="c-label">@lang.KEYWORD</label>
            @Html.TextBox("arrNews[0].SEO", arrNews[0].SEO, new { @class = "input t-input", required = "required" })
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.PINHOME</label>
            @Html.CheckBox("arrNews[0].IsPin", arrNews[0].IsPin)
        </div>
        <div class="row">
            <label class="c-label left">@lang.NEWSTYPE</label>
            
            @Html.Telerik().NumericTextBox().Value(arrNews[0].TypeID).Name("arrNews[0].TypeID").MinValue(1).MaxValue(2)
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.DESCRIPTION</label>
            @Html.TextArea("arrNews[0].Description", arrNews[0].Description, new { @class = "input t-input", required = "required" })
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.FILEUPLOAD</label>
            @(Html.Telerik().Upload()
            .Name("attachments")
            .Multiple((bool)ViewData["multiple"])
            .Async(async => async
                .Save("Save", "Upload")
                .Remove("Remove", "Upload")
                .AutoUpload((bool)ViewData["autoUpload"])
                ).ClientEvents(events => events
                    .OnSuccess("onSuccess")
                    )
            )
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.IMAGE</label>
            @Html.TextBox("arrNews[0].Image", arrNews[0].Image, new { @class = "input t-input", required = "required" })
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.CONTENT</label>
            <div class="clear"></div>
            @{ Html.Telerik().Editor().Name("arrNews[0].Content").Value(arrNews[0].Content)
           .HtmlAttributes(new { style = "height:400px", required = "required" })
           .Encode(false)
           .Value(arrNews[0].Content)
               .Render();
            }
        </div>
    </div>
    <div id="c-english" class="left">
        <h2 class="sub-title">@lang.ENGLISH</h2>
        @Html.Hidden("arrNews[1].ID", arrNews[1].ID)
        @Html.Hidden("arrNews[1].LangID", arrNews[1].LangID)
        <div class="row">
            <label class="c-label">@lang.TITLE</label>
            @Html.TextBox("arrNews[1].Title", arrNews[1].Title, new { @class = "input t-input", required = "required" })
        </div>
        <div class="row">
            <label class="c-label">@lang.KEYWORD</label>
            @Html.TextBox("arrNews[1].SEO", arrNews[1].SEO, new { @class = "input t-input", required = "required" })
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.PINHOME</label>
            @Html.CheckBox("arrNews[1].IsPin", arrNews[1].IsPin)
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.NEWSTYPE</label>
            @Html.Telerik().NumericTextBox().Value(arrNews[1].TypeID).Name("arrNews[1].TypeID").MinValue(1).MaxValue(2)
        </div>
        <div class="row">
            <label class="c-label left">@lang.DESCRIPTION</label>
            @Html.TextArea("arrNews[1].Description", arrNews[1].Description, new { @class = "input t-input", required = "required" })
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.FILEUPLOAD</label>
            @(Html.Telerik().Upload()
            .Name("attachments1")
            .Multiple((bool)ViewData["multiple"])
            .Async(async => async
                .Save("Save", "Upload")
                .Remove("Remove", "Upload")
                .AutoUpload((bool)ViewData["autoUpload"])
                ).ClientEvents(events => events
                    .OnSuccess("onSuccess")
                    )
            )
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.IMAGE</label>
            @Html.TextBox("arrNews[1].Image", arrNews[1].Image, new { @class = "input t-input", required = "required" })
        </div>
        <div class="row">
            <label class="c-label left" style="width: 150px;">@lang.CONTENT</label>
            <div class="clear"></div>
            @{ Html.Telerik().Editor().Name("arrNews[1].Content").Value(arrNews[1].Content)
           .HtmlAttributes(new { style = "height:400px", required = "required" })
           .Encode(false)
           .Value(arrNews[1].Content)
               .Render();
            }
        </div>
    </div>
    <p>
        <button type="submit" class="t-button t-state-default">
            @lang.POSTNEWS</button>
    </p>
</div>
@{ Html.EndForm(); }
<style type="text/css">
    .editor-output
    {
        font: normal 1em/1.1em "Consolas" , "Monaco" , "Bitstream Vera Sans Mono" , "Courier New" , Courier, monospace;
        border: 1px solid #ccc;
        background: #fff;
        display: block;
        padding: 4px 8px 8px;
    }
    .t-file a
    {
        float: right;
    }
</style>
<script type="text/javascript">
    function onSuccess(e) {
        getFileInfo(e);
    }
    function getFileInfo(e) {
        return $.map(e.files, function (file) {
            var info = file.name;
            var file = $(".t-filename[title$='" + info + "']");
            var a = $("<a>").attr("target", "_blank").attr("href", "/FileUpload/" + info).text("http://localhost:5844/FileUpload/" + info); a.appendTo(file.parent());
            if (file.size > 0) {
                info += " ("
        + Math.ceil(file.size / 1024) + " KB)";
            }
            return info;
        }).join(", ");
    } 
</script>
